﻿package mortal.game.view.ThanksGiving.panel
{
    import com.gengine.core.frame.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.data.*;
    import mortal.game.resource.*;
    import mortal.game.view.ThanksGiving.data.*;
    import mortal.game.view.ThanksGiving.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class ThanksGivingRedBagPanel extends GSprite
    {
        protected var _mbg:GImageBitmap;
        protected var _day:BitmapNumberText;
        protected var _hour:BitmapNumberText;
        protected var _min:BitmapNumberText;
        protected var _sec:BitmapNumberText;
        protected var _list:GTileList;
        private var _secT:SecTimer;
        private var _arr:Array;

        public function ThanksGivingRedBagPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._mbg = UIFactory.gImageBitmap(ImagesConst.ThanksGivingRedBagBg, 0, 0, this);
            this._day = UIFactory.bitmapNumberText(153, 110, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._day.text = "00";
            this._hour = UIFactory.bitmapNumberText(208, 110, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hour.text = "00";
            this._min = UIFactory.bitmapNumberText(279, 110, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._min.text = "00";
            this._sec = UIFactory.bitmapNumberText(350, 111, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._sec.text = "00";
            this._list = UIFactory.tileList(0, 192, 698, 363, this);
            this._list.direction = GBoxDirection.VERTICAL;
            this._list.verticalGap = 2;
            this._list.horizontalGap = 2;
            this._list.rowHeight = 121;
            this._list.columnWidth = 683;
            this._list.columnCount = 1;
            this._list.rowCount = 3;
            this._list.width = 698;
            this._list.setStyle("cellRenderer", ThanksGivingRedBagCell);
            this._secT = new SecTimer(1);
            this._secT.addListener(TimerType.ENTERFRAME, this.timeCk);
            this._secT.start();
            this.timeCk(null);
            this.updateRuleAndTime();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._secT.stop();
            this._secT.dispose(param1);
            this._secT = null;
            this._arr = null;
            this._mbg = null;
            this._day = null;
            this._hour = null;
            this._min = null;
            this._sec = null;
            this._list = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function timeCk(param1:SecTimer) : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            _loc_2 = ThanksGivingUtil.getDayCountDownTime();
            _loc_3 = _loc_2[5];
            this._day.text = "" + _loc_2[0];
            this._hour.text = "" + _loc_2[1];
            this._min.text = "" + _loc_2[2];
            this._sec.text = "" + _loc_2[3];
            if (_loc_3 > 0)
            {
                if (this._secT.running == false)
                {
                    this._secT.start();
                }
                this.updateList();
            }
            else
            {
                this._secT.stop();
            }
            return;
        }// end function

        private function updateRuleAndTime() : void
        {
            return;
        }// end function

        public function updateList() : void
        {
            var _loc_2:int = 0;
            var _loc_3:Object = null;
            if (this._list == null)
            {
                return;
            }
            if (this._arr == null)
            {
                this._arr = [];
                _loc_2 = 0;
                while (_loc_2 < 3)
                {
                    
                    _loc_3 = {};
                    _loc_3.index = _loc_2;
                    this._arr.push(_loc_3);
                    _loc_2++;
                }
            }
            var _loc_1:* = new DataProvider(this._arr);
            this._list.dataProvider = _loc_1;
            return;
        }// end function

    }
}
